package org.cytoscape.myapp.cytoscape_app_v1.internal.tasks.groups;

import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.group.CyGroupFactory;
import org.cytoscape.group.CyGroupManager;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.myapp.cytoscape_app_v1.internal.model.StateExpanded;
import org.cytoscape.task.NetworkTaskFactory;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.TaskIterator;
import org.cytoscape.work.TaskManager;

public class GroupsTaskFactory implements TaskFactory {
	protected CyApplicationManager applicationManager;
	protected CyGroupManager groupManager;
	protected CyGroupFactory groupFactory;
	protected String attr;
	@SuppressWarnings("rawtypes")
	
public GroupsTaskFactory(CyApplicationManager applicationManager, CyGroupManager groupManager, CyGroupFactory groupFactory,
			String attr ){
	this.applicationManager = applicationManager;
	this.groupManager = groupManager;
	this.groupFactory = groupFactory;
	this.attr = attr;

}

@Override
	public TaskIterator createTaskIterator() {
		TaskIterator taskIterator = new TaskIterator();
		Task groupTask =  new GroupsCreationTask(applicationManager, groupManager, groupFactory,
				attr);
		Task groupsRemoveTask = new GroupsRemoveTask(applicationManager, groupManager);
		Task groupsExpandTask = new GroupCollapsedExpandTask(applicationManager, groupManager,new StateExpanded(applicationManager));
		
		taskIterator.append(groupsRemoveTask);
		
		taskIterator.insertTasksAfter( groupsRemoveTask, groupTask);
		//taskIterator.append(groupTask);
		taskIterator.insertTasksAfter(groupTask, groupsExpandTask);
		
		return taskIterator;
	}

	@Override
	public boolean isReady() {
		// TODO Auto-generated method stub
		return false;
	}

}
